﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using YasharEl.Infrastructure.EntityModel;
using YasharEl.Infrastructure.ResourcesManagement;
using System.Globalization;

namespace YasharEl.Infrastructure.OrgUnit
{
    [Serializable]
    public class OrganizationalUnitNotFoundException : TranslatedDomainModelException
    {
        private const string OrganizationalUnitNotFound = "OrganizationalUnitNotFound";

        private readonly long _unitId;

        public long UnitId
        {
            get { return _unitId; }
        }

        public OrganizationalUnitNotFoundException(IResourceManager resourceManager, long unitId)
            : base
             (
                resourceManager,
                string.Format(
                    resourceManager.GetString(OrganizationalUnitNotFound, CultureInfo.GetCultureInfo("en")),
                    unitId
                )
             )
        {
            _unitId = unitId;
        }

        protected OrganizationalUnitNotFoundException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        protected override string ExceptionMessageResourceKey
        {
            get { return OrganizationalUnitNotFound; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ExceptionMessageResourceKey), UnitId);
            }
        }
    }
}
